// https://nuxt.com/docs/api/configuration/nuxt-config
import path from "path"
import { getApiBaseUrl } from "./utils/environment"
export default defineNuxtConfig({
  compatibilityDate: "2025-05-13",
  app: {
    head: {
      title: process.env.PAGE_TITLE,
      meta: [
        {
          name: "description",
          content: "我的自定义描述",
        },
      ],
      link: [
        {
          rel: "icon",
          type: "image/png",
          href: "/images/logo2.png",
        },
      ],
    },
  },
  ssr: true,
  devtools: { enabled: true },
  modules: ["@nuxt/scripts", "@nuxt/eslint", "nuxt-svgo", "@pinia/nuxt"],
  css: ["~/assets/css/index.css"],
  postcss: {
    plugins: {
      "@tailwindcss/postcss": {},
    },
  },
  vite: {
    resolve: {
      alias: {
        "@": path.resolve(__dirname, "./"),
      },
    },
    server: {
      proxy: {
        // 在vite中配置代理
        [process.env.API_PREFIX as string]: {
          target: process.env.API_BASE_URL,
          changeOrigin: true,
          rewrite: (path: string) => path.replace(new RegExp(`^${process.env.API_PREFIX}`), ""),
        },
      },
    },
  },
  nitro: {
  },
  devServer: {
    host: "0.0.0.0",
    port: 3000,
    // 允许跨域
    cors: {
      origin: "*",
    },
  },
  runtimeConfig: {
    public: {
      MAP_APP_KEY: process.env.MAP_APP_KEY,
      apiBaseUrl: getApiBaseUrl(),
    },
  },
})
